package com.ssy.lingxi.after.sale.serviceimpl;

import com.ssy.lingxi.after.sale.entity.EvaluateDO;
import com.ssy.lingxi.after.sale.model.bo.EvaluateBO;
import com.ssy.lingxi.after.sale.repository.EvaluateRepository;
import com.ssy.lingxi.after.sale.service.IEvaluateService;
import com.ssy.lingxi.common.response.Wrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 评价接口服务实现
 * @author 伍将
 * @date 2020/9/3
 * @version 2.0.0
 */
@Service
public class EvaluateServiceImpl implements IEvaluateService {

    @Resource
    private EvaluateRepository evaluateRepository;

    /**
     * 根据售后id与售后类型获取评价
     * @author 伍将
     * @date 2020/9/3
     * @param afterSaleId:售后id
     * @param afterSaleType:售后类型
     * @return com.ssy.lingxi.common.response.Wrapper<com.ssy.lingxi.after.sale.model.bo.EvaluateBO>
     **/
    @Override
    public Wrapper<EvaluateBO> getDetail(Long afterSaleId, Integer afterSaleType) {

        EvaluateBO result = null;
        EvaluateDO evaluateDO = evaluateRepository.findByAfterSaleIdAndAfterSaleType(afterSaleId, afterSaleType);
        if (evaluateDO != null) {
            result = new EvaluateBO();
            result.setLevel(evaluateDO.getLevel());
            result.setContent(evaluateDO.getContent());
        }

        return Wrapper.success(result);
    }
}
